<?php
class Province_city_model extends HYD_Model {
    private $_sql_where = '';
    
    public function __construct(){
        $this->set_table_name('public_province');
    }

    /**
     * 取由节点“id、名称”组成的数组用于显示select选单
     * @return array
     */
    public function get_select_province($order_by = NULL) {        
        $this->db->select('provinceID as id, province as text ');
        $this->db->from($this->get_table_name());

        if (!is_null($order_by)) {
            $this->db->order_by($order_by);
        }
        $this->db->order_by('id');
        $result_list = $this->db->get();
        return $result_list->result_array();
    }

    /**
     * 取由节点“id、名称”组成的数组用于显示select选单
     * @return array
     */
    public function get_select_city($fid = NULL,$order_by = NULL) {        
        $this->db->select('cityID as id, city as text ');
        $this->db->from('public_city');

        if (!is_null($fid)) {
            $this->db->where('father', $fid);
        }
        if (!is_null($order_by)) {
            $this->db->order_by($order_by);
        }
        $this->db->order_by('id');
        $result_list = $this->db->get();
        return $result_list->result_array();
    }
    /**
     * 取由节点“id、名称”组成的数组用于显示select选单
     * @return array
     */
    public function get_province_arr($id = NULL) {        
        $this->db->select('provinceID as id, province as name ');
        $this->db->from($this->get_table_name());
        $this->db->where('provinceID', $id);
        $result_list = $this->db->get();
        return $result_list->row_array();
    }
    /**
     * 取由节点“id、名称”组成的数组用于显示select选单
     * @return array
     */
    public function get_city_arr($id = NULL) {        
        $this->db->select('cityID as id, city as name ');
        $this->db->from('public_city');
        $this->db->where('cityID', $id);
        $result_list = $this->db->get();
        return $result_list->row_array();
    }
}